package com.zjw.core.collection;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @description:
 * @author: zhangjiawei
 * @createTime:2022/3/29 15:55
 * @modified by:
 */
public class ComparableExample {

    public static void main(String[] args) {
        Artist artist = new Artist(1,"张佳伟",28);
        Artist artist2 = new Artist(2,"伍鹏",26);
        Artist artist3 = new Artist(3,"猴年",27);

        System.out.println(artist.compareTo(artist2));
        System.out.println(artist.compareTo(artist3));
        System.out.println(artist2.compareTo(artist2));

        ArrayList<Artist> arrayList = new ArrayList<>();
        arrayList.add(artist);
        arrayList.add(artist2);
        arrayList.add(artist3);

        Collections.sort(arrayList);
        System.out.println(arrayList);

    }
}
